<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@include file="../connection.jsp"%>
<%

  //HttpSession session = request.getSession();
  //session = request.getSession();
  
  String userid = (String)session.getAttribute("admin");
  
  if(userid==null)
  {
  	response.sendRedirect("../login.jsp");
  }  
   
   String email = request.getParameter("email");
   String message="";
   
    Connection c = getAdminConnection();	
	Statement s = c.createStatement();    
	String currentEmail="";
	
	

   if(email!=null){
	
			s.executeUpdate("delete from adminemail");
			s.executeUpdate("insert into adminemail values('"+email+"')");
			message = "Email address saved successfully."; 
}
ResultSet rs = s.executeQuery("select email from adminemail");
if(rs.first()){
		currentEmail=rs.getString(1);
}
		rs.close();
        s.close();
		c.close();
        
   
   
  %>
<html>
<head>
<link href="../css/medbill.css" rel="stylesheet" type="text/css" />
<title>PMS Home</title>
<script language="javascript">

function validateForm(){

  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		var address = document.getElementById("email").value;
		if(reg.test(address) == false) {
			alert('Invalid Email Address');
        	 document.getElementById("email").focus();
			 return false;
     	}  	
   return true;
}
</script>
</head>
<body>
<table width="860" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="204" valign="top"><%@include file="header.jsp"%></td>
  </tr>
  <tr>
    <td height="30" bgcolor="#1f226f" class="headingBlue">Medical Billing and Claim Processing Professionals</td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#ccae74"><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="470" valign="top" class="txtPageTitle">Admin Email </td>
            <td>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="560"></td>
              </tr>
              <tr>
                <td class="txtHomeBody"></td>
              </tr>
            </table>
              <br>
<form name="ChangePassword" onsubmit="return validateForm();" action="adminemail.jsp" method="post">
  <div>
  <table border="0" width="400" cellpadding="0">
  <tr>
		<td width="394" colspan="2"><font color='red'><%=message%></font></td>
	</tr>
	<tr>
		<td width="120" align="left">Email:</td>
		<td width="274">
    <input type="text" name="email" id="email" size="20" value="<%=currentEmail%>"/></td>
	</tr>
	
	<tr>
		<td width="120">&nbsp;</td>
		<td width="274">&nbsp;</td>
	</tr>
	<tr>
		<td width="120">&nbsp;</td>
		<td width="274"><input type="submit" value="Save"/> 
		<input type="button" value="Cancel" onclick="location='home.jsp';"/></td>
	</tr>
	</table>
  </div>
</form><br />
<br />
<br />
<br />
<br /><br />
<br />

			  </td>
            <td width="45" valign="top">&nbsp;</td>
            <td valign="top">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="62" valign="top"><!-- #BeginLibraryItem "/Library/footer.lbi" --><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="4" bgcolor="#c7540f"></td>
      </tr>
      <tr>
        <td height="58" bgcolor="#1e2667">&nbsp;</td>
      </tr>
    </table><!-- #EndLibraryItem --></td>
  </tr>
</table>
</body>
</html>
